// pages/index/component/shopHeader.js
import { find } from "../../../../api/shop";
const utils = require('../../../../utils/util.js')
const app = getApp()
Component({

  /**
   * 组件的属性列表
   */
  properties: {

  },

  /**
   * 组件的初始数据
   */
  data: {
    concise: true,
    products: [],
    pageSize: 2,
    pageNum: 1,
    tagIds: [],
    shopInfo: {}
  },

  lifetimes: {
    attached() {
      this.loadShop()
    }
  },
  /**
   * 组件的方法列表
   */
  methods: {
    loadShop() {
      var _this = this
      find(app.globalData.wxPageShopId).then(res => {
        this.data.shopInfo = res.data.shop;
        this.setData({
          shopInfo:this.data.shopInfo
        })
      })
    },
    callTel(e) {
        const { tel } = e.currentTarget.dataset
        wx.makePhoneCall({
            phoneNumber: tel// 仅为示例，并非真实的电话号码
        })
    },
    navigate(e) {
        const { item } = e.currentTarget.dataset
        console.log(item);
        if (item.lat == null && item.lng == null) {
            this.data.lat = 24.46;
            this.data.lng = 118.1;
        } else {
            this.data.lat = item.lat;
            this.data.lng = item.lng;
        }
        let params = {   //使用微信内置地图查看标记点位置，并进行导航
            latitude: this.data.lat,//要去的纬度-地址
            longitude: this.data.lng,//要去的经度-地址
            name:item.name,
            address:item.address
        }
        wx.openLocation(params)
    },
  }
})